package package2;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * @author lzy
 * @version v1.0
 * Create DateTime: 2019/10/31 16:24
 */
public class ClassB {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
        // error: g()不可访问
//        ClassA.getC().g();
        Class c = Class.forName("package1.C");
        final Method method = c.getMethod("g");
        method.setAccessible(true);
        method.invoke(c);
    }
}
